package oa.hleast.xswl.controller.app;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import oa.hleast.common.result.Result;
import oa.hleast.xswl.pojo.vo.article.HomePageArticleVo;
import oa.hleast.xswl.pojo.vo.web.*;
import oa.hleast.xswl.service.ISysCommonConfigService;
import oa.hleast.xswl.service.ISysDictItemService;
import oa.hleast.xswl.service.IWebService;
import oa.hleast.xswl.service.banner.IWebsiteBannerService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * @author 302
 * @description
 * @date 2021/3/17
 */
@Api(tags = "【移动端】web展示通用")
@RestController
@RequestMapping("/api.app/v1/web")
@AllArgsConstructor
@Slf4j
public class WebController {

    private final IWebsiteBannerService websiteBannerService;
    private final ISysCommonConfigService commonConfigService;
    private final IWebService webService;
    private final ISysDictItemService iSysDictItemService;

    @ApiOperation(value = "城市大脑首页", httpMethod = "GET")
    @GetMapping("/getServeData")
    public Result<HomePageServeDataVo> getServeData() {
        HomePageServeDataVo homePageDataVo = webService.getCityBrainServeData();
        return Result.success(homePageDataVo);
    }

    @ApiOperation(value = "萧山文旅红首页", httpMethod = "GET")
    @GetMapping("/getRedTourismServeData")
    public Result<HomePageRedTourismServeDataVo> getRedTourismServeData() {
        HomePageRedTourismServeDataVo homePageDataVo = webService.getRedTourismServeData();
        return Result.success(homePageDataVo);
    }

    @ApiOperation(value = "云集市页面数据", httpMethod = "GET")
    @GetMapping("/getCloudMarketServeData")
    public Result<HomePageCloudMarketServeDataVo> getCloudMarketServeData() {
        HomePageCloudMarketServeDataVo homePageDataVo = webService.getCloudMarketServeData();
        return Result.success(homePageDataVo);
    }

    @ApiOperation(value = "云课堂", httpMethod = "GET")
    @GetMapping("/getCloudClassroomServeData")
    public Result<HomePageArticleVo> getCloudClassroomServeData() {
        HomePageArticleVo vo = webService.getCloudClassroomServeData();
        return Result.success(vo);
    }

    @ApiOperation(value = "研学风采", httpMethod = "GET")
    @GetMapping("/getResearchServeData")
    public Result<HomePageArticleVo> getResearchServeData() {
        HomePageArticleVo vo = webService.getResearchServeData();
        return Result.success(vo);
    }



    @ApiOperation(value = "根据配置key获取轮播图", httpMethod = "GET")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page", value = "页码", paramType = "query", dataType = "Long",dataTypeClass = Long.class),
            @ApiImplicitParam(name = "limit", value = "每页数量", paramType = "query", dataType = "Long",dataTypeClass = Long.class),
            @ApiImplicitParam(name = "configKey", value = "配置key", paramType = "query", dataType = "String",dataTypeClass = String.class)
    })
    @GetMapping("/getWebsiteBannerPageByKey")
    public Result<List<HomePageWebsiteBannerVo>> getWebsiteBannerPageByKey(@RequestParam @NotNull Integer page,
                                                                           @RequestParam @NotNull Integer limit,
                                                                           @RequestParam @NotNull String configKey) {
        Page<HomePageWebsiteBannerVo> result = websiteBannerService.getWebsiteBannerPageByKey(page, limit, configKey);
        return Result.success(result.getRecords());
    }

    @ApiOperation(value = "商城页数据", httpMethod = "GET")
    @GetMapping("/getMallData")
    public Result<HomePageMallDataVo> getMallData() {
        HomePageMallDataVo vo = webService.getMallData();
        return Result.success(vo);
    }

}
